package steps
{
	import jnBase.BaseZhishi;
	import jnBase.Data;
	import jnBase.InsPages;
	import jnBase.PSteps;
	
	import laya.display.Sprite;
	import laya.utils.Handler;
	import laya.utils.Tween;
	
	import ui.steps.step4_MXquxianUI;

	public class Step04_MXQuXian extends step4_MXquxianUI implements InsPages
	{
		public var _scriptPage:PSteps;
		public var _scriptZhishi:BaseZhishi;
		private var zhishiStr:String="";
		public function Step04_MXQuXian()
		{
			super();
			size(1920,1080);
			this.name="4.脉搏、心率曲线的绘制";
			_scriptPage=this.addComponent(PSteps);
			_scriptZhishi=this.addComponent(BaseZhishi);
		}
		public function changeSonStep():void
		{
			step1();
		}
		
		
		private var sp:Sprite = new Laya.Sprite();
		
		private function step1():void
		{	

			_scriptZhishi.showTips("每一小格为4次/分，将实际测量的脉率或心率，用红笔绘制于体温单相应时间格内");
			
			Laya.timer.once(4000,this,function():void{
				Tween.to(m1,{alpha:1},500);
				Tween.to(m2,{alpha:1},500);
				Tween.to(m3,{alpha:1},500);
				_scriptZhishi.showTips("相邻脉率或心率以红线相连，相同两次脉率或心率间可不连线");
				_scriptZhishi.xiankuangClick(721,585,106,131,function():void{
					
					_scriptZhishi.clearLoop();
					_scriptZhishi.hideLine();
					//划线
					Laya.stage.addChild(sp);
					sp.graphics.drawLine(734,703,799,605,"#f00",3);
					sp.graphics.drawLine(799,605,876,558,"#f00",3);
					
					Laya.timer.once(2000,this,function():void{
						_scriptZhishi.showTips("脉搏与体温重叠时，先画体温符号，再用红笔在外画红圈“О”");
						_scriptZhishi.xiankuangClick(903,475,46,46,function():void{
							_scriptZhishi.clearLoop();
							_scriptZhishi.hideLine();
							
							Tween.to(m4,{alpha:1},500);
							sp.graphics.drawLine(876,558,926,503,"#f00",3);
							
							Laya.timer.once(2000,this,function():void{
								_scriptZhishi.showTips("如系肛温，则先以蓝圈表示体温，其内以红点表示脉搏");
								_scriptZhishi.xiankuangClick(940,463,46,46,function():void{
									_scriptZhishi.clearLoop();
									_scriptZhishi.hideLine();
									
									Tween.to(m5,{alpha:1},500);
									sp.graphics.drawLine(926,503,963,490,"#f00",3);
									Tween.to(m6,{alpha:1},500);
									sp.graphics.drawLine(963,490,1007,575,"#f00",3);
									Laya.timer.once(2000,this,function():void{
										_scriptZhishi.showTips("提示：脉搏短绌时，相邻脉率或心率用红线相连，在脉率与心率之间用红笔画线填满");
										Laya.timer.once(5000,this,function():void{
											_scriptPage.addPage(4);
										});
									});
								});
								
							});
						});
						
					});
				});
				
			});
			
		}	


	
		
		/**
		 *切换二级菜单时自动调用
		 * 显示新的二级页面时会自动调用此方法 
		 * 
		 */		
		public function reset():void
		{
			_scriptZhishi.hideAll();
			removeAllListener();
			zhishiStr="";
			sp.graphics.clear();
		}
		/**
		 *移除所有监听 
		 * 
		 */		
		public function removeAllListener():void
		{
			_scriptZhishi.removeAllHandler();	
			sp.graphics.clear();
		}
		override public function onEnable():void{
			reset();
		}
		/**
		 *关闭时自动调用 
		 * @param type
		 * 
		 */		
		override public function close(type:String=null):void
		{
			// TODO Auto Generated method stub
			_scriptPage.enabled=false;
			_scriptZhishi.enabled=false;
			removeAllListener();
			Tween.to(this,{x:-GameConfig.width,alpha:0},300,null,Handler.create(this,closeSuper,[type]));
		}
		private function closeSuper(type:String=null):void{
			super.close(type);
		}
		/**
		 *每秒执行一次 
		 * 
		 */		
		public function lineLoop():void
		{
			// TODO Auto Generated method stub
			if(zhishiStr==""){
				_scriptZhishi.zhishiRect.alpha=1;
				Tween.to(_scriptZhishi.zhishiRect,{alpha:0.1},600);
			}
			else if(zhishiStr=="xi"){
				_scriptZhishi.mdown.visible=true;
				_scriptZhishi.mdown.pos(958,688);
				_scriptZhishi.mdown.rotation=-155;
				Tween.to(_scriptZhishi.mdown,{x:990,y:596},600);
			}
		}
		/**
		 *被移除时自动调用  
		 * 因为设置了自动销毁，所以关闭后后会执行销毁 ，因为关闭时加了一个动画，所以要300毫秒后才执行销毁
		 * 
		 */		
		override public function onDestroy():void{
			trace(this.name+"销毁");
		}
	}
}